package com.ttl.bc.stock.request2.bean;

import org.displaytag.decorator.TableDecorator;


public class BCStkIssue2Decorator extends TableDecorator {

	public String getIttl_status() {
		BCStkIssue2ShowBean obj = (BCStkIssue2ShowBean)getCurrentRowObject();
				
		if (obj.getIttl_status()!=null && obj.getIttl_status().equals("0")) {
			return "รอเบิก";
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("1")) {
			return "จ่ายแล้ว";
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("4")) {
			return "รับแล้ว";			
		}else {
			return "สถานะไม่ถูกต้อง";
		}						
	}
	
	public String getQty1() {
					
		BCStkIssue2ShowBean obj = (BCStkIssue2ShowBean)getCurrentRowObject();
		float qty = obj.getQty();
				
		return "<label align = 'right'>"+qty+"</label>";

	}
	
	public String getMode() {
		
		//BCStkIssue2 obj = (BCStkIssue2)getCurrentRowObject();
		
		BCStkIssue2ShowBean obj = (BCStkIssue2ShowBean)getCurrentRowObject();
		String docNo = obj.getDocNo();				
		
		String delete = "";
		String edit = "";
		String print = "<a href=\"/ittl/Report.do?mode=printStockRequest&docNo="+docNo+"\" target=\"_blank\">Print</a>";		
		String price = "";
		if (obj.getIttl_status()!=null && obj.getIttl_status().equals("0")) {
			delete = "<a href=\"/ittl/StkReq.do?mode=cancel&docNo="+docNo+"\">ลบ</a> | ";
			edit = "<a href=\"/ittl/StkReq.do?mode=edit&docNo="+docNo+"\">แก้ไข</a> | ";
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("1")) {
			String ttl = docNo.substring(0, 2);
			if(ttl.equalsIgnoreCase("F2")) {
				price = "<a href=\"/ittl/StkReq.do?mode=receiveConfirmShow&docNo="+docNo+"\">รับของ</a>";
				print = "";
			}else {
				price = "";//"<a href=\"/ittl/StkReq.do?mode=price&docNo="+docNo+"\">ใส่ราคา</a> | ";
			}
		}else if (obj.getIttl_status()!=null && obj.getIttl_status().equals("4")) {
			price = "<a href=\"/ittl/StkReq.do?mode=receiveCancelShow&docNo="+docNo+"\">ยกเลิกการรับ</a> | ";
						
		}else {//ittl_status=-1 หรืออื่นๆ
			price = "<a href=\"/ittl/StkReq.do?mode=cancelOfDelete&docNo="+docNo+"\">ยกเลิกการลบ</a>";
			print = "";
		}
		
		return "<center>"+delete+edit+price+print+"</center>";						
		
	}
			
}
